<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>ManagerManager for Modx: Function reference: Widgets</title>
<link href="css/mm.css" rel="stylesheet" type="text/css" />


</head>

<body>

<div id="banner">

</div>


<div id="main">
    <div id="nav">
        <ul>
            <li><a href="index.htm">Introduction</a></li>
            <li><a href="install.htm">Installation</a></li>
            <li><a href="getting-started.htm">Getting started</a></li>
            <li><a href="field-names.htm">Field names</a></li>
            <li><a href="fields.htm">Fields</a></li>
            <li><a href="tabs.htm">Tabs</a></li>
            <li>Widgets</li>
            <li><a href="sections.htm">Sections</a></li>
            <li><a href="changelog.htm">Changelog</a></li>
        </ul>   
    </div>
    
  <div id="content">
      <h1>Function reference: Widgets</h1>
      <h2>mm_widget_tags($fields, $delimiter, $source, $display_count, $roles, $templates)</h2>
      <p><img src="images/tags.jpg" width="441" height="47" alt="Tags demo" /></p>
      <p>Changes the manager widget for this text field to tag-friendly format - e.g. it will display a clickable list of all other tags which have been used for this field.</p>
      <p><strong>$fields: </strong>The name(s) of the template variables this should apply to. Can accept multiple field separated by a comma. [Required]<br />
          <strong>$delimiter:</strong> Which character separates individual tags within this field [Optional - default is comma)<br />
          <strong>$source:</strong> The names(s) of the template variables the list of tags should come from. This allows the list of tags to come from a different field that the widget. By default it uses all the TVs listed in $fields [Optional - default is same as $fields] <br />
          <strong>$display_count:</strong> Display the number of documents using each tag (in brackets after it) [Optional - boolean - default is false] <br />
          <strong>$roles:</strong> comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]<br />
          <strong>$templates: </strong>comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]</p>
      <p><code>mm_widget_tags('docTags'); // Adds the tag editing widget to the docTags template variable wherever it appears</code><code>mm_widget_tags('docTags,blogTags'); // Adds the tag editing widget to the docTags and blogTags template variables wherever they appear - making all previous values from both template variables available in both tags</code><code>mm_widget_tags('docTags', ',', '', '1', '', '2'); // Adds the tag editing widget to the docTags template variables in template 2, and shows the number of times each tag has been used</code></p>
      <p>Note: TV(s) must be a text input field</p>
      <h2> mm_widget_showimagetvs($fields, $w, $h, $thumbnailerUrl, $roles, $templates)</h2>
      <p><img src="images/image-preview.jpg" alt="Show Image preview" /></p>
      <p>Emulates the ShowImageTVs plugin - shows a preview of images chosen in image TVs.</p>
      <p><strong>$fields: </strong>The name(s) of the template variables this should apply to. Can accept multiple field separated by a comma. [Optional - default is to use all image TVs]<br />
          <strong>$w:</strong> Preferred maximum width of the preview [Optional - default is 300]<br />
          <strong>$h:</strong> Preferred maximum height of the preview [Optional - default is 100]<br />
          <strong>$thumbnailerUrl:</strong> If you have PHPThumb installed (for example through Maxigallery or phpthumb plugins/snippets), use this to make thumbnails rather than resizing the image previews via CSS. Particularly useful if you are using very large pictures, which would take a long time to download. [Optional - url] <br />
          <strong>$roles:</strong> comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]<br />
          <strong>$templates: </strong>comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]</p>
      <p><code>mm_widget_showimagetvs(); // Adds an image preview to every Image-type template variable</code><code>mm_widget_showimagetvs('', 150, 150); // Adds a 150x150px image preview to every Image-type template variable</code><code>mm_widget_showimagetvs('mypic', '300', '200', '/assets/snippets/phpthumb/phpThumb.php', '', '2'); // Adds an image preview to the mypic template variables in template 2, resized to 300x200px using phpthumb at the URL supplied</code></p>
      <p>Note: TV(s) must be an image input field</p>
      <h2>mm_widget_colors($fields, $default, $roles, $templates)</h2>
      <p><img src="images/color-picker.jpg" alt="Color picker" /></p>
      <p>Turns a text field into a color picker - storing the chosen hex value in the field.</p>
      <p><strong>$fields: </strong>The name(s) of the template variables this should apply to. Can accept multiple field separated by a comma. [Required]<br />
          <strong>$default:</strong> Which color should be selected by default in new documents. This is only used in situations where the TV does not have a default value specified in the TV definition [Optional - default is white)<br />
          <strong>$roles:</strong> comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]<br />
          <strong>$templates: </strong>comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]</p>
      <p><code>mm_widget_colors('bgcolor'); // Adds the color picker widget to the bgcolor template variable wherever it appears</code><code>mm_widget_colors('bgcolor,foreground'); // Adds the color picker widget to the bgcolor and foreground template variables wherever they appear</code><code>mm_widget_colors('bgcolor', '#000000', '1', '2'); // Adds the color picker widget to the bgcolor template variable, with a default value of black for new documents, only for role 1 and documents using template 2</code></p>
      <p>Note: TV(s) must be a text input field</p>
      <p>&nbsp;  </p>
      <h2>mm_widget_accessdenied($ids, $message, $roles)      </h2>
      <p>Denies access to specific documents (by ID) without inheritance.</p>
      <p>For example, if the parent document has some Ditto call (which you do not want a user to edit) but want to allow them to create child documents.</p>
      <p class="warning">Use this plugin with caution, as while it offers a basic level of protection, it does not prevent access to documents in the same way as ModX's permissions system. It would be possible for a user with technical knowledge to override it. Think of it as a &quot;No entry&quot; sign for an unlocked door, rather than a lock.</p>
      <p>Originally contributed by Metaller</p>
      <p><strong>$ids: </strong>comma separated list of  documents ID to prevent access. [Required]<br />
        <strong>$message:</strong> HTML formatted message [Optional - default is &quot;Access denied - Access to current document closed for security reasons.&quot;)<br />
        <strong>$roles:</strong> comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]<br />
    </p>
      <p><code>mm_widget_accessdenied('1,15'); // Prevents all users from accessing documents 1 and 15 (displaying default message)</code><code>mm_widget_accessdenied('1,15', 'Please select another document to edit' '2'); // Prevents  users with role 2 from accessing documents 1 and 15 (displaying custom message)</code></p>
  </div>
</div>
</body>
</html>
